package org.ricks.net.action.context.head;

import java.nio.ByteBuffer;

public class DefInnerHeadMeta implements HeadMeta {
    protected byte mark;
    protected final short cmd;

    public DefInnerHeadMeta(byte mark, short cmd) {
        this.mark = mark;
        this.cmd = cmd;
    }

    @Override
    public int cmd() {
        return cmd;
    }

    @Override
    public byte flags() {
        return mark;  // 修复：添加flags实现
    }

    public byte getMark() {
        return mark;
    }

    @Override
    public ByteBuffer generateHeader(ByteBuffer buffer) {
        if (buffer.capacity() < 3) {
            buffer = ByteBuffer.allocate(3);
        }
        buffer.clear();
        buffer.put(mark);
        buffer.putShort(cmd);
        buffer.flip();
        return buffer;
    }
}